﻿using System;
using System.Collections;
using System.Linq;
using System.Text;

namespace KiMoCSys.core
{
    /// <summary>
    /// This is basically a simple list for every frame captured from kinect device, so when the time comes,
    /// we have to take this list to an XML collada file.
    /// </summary>
    class FrameSkeletonManager
    {

        /// <summary>
        /// Each position in this list, represents a list of frames captured from a specific kinect device [Device0 ,Device1 ,etc..]
        /// </summary>
        ArrayList list;

        private static FrameSkeletonManager singleton;

        public static FrameSkeletonManager getSingleton()
        {
            if (singleton == null)
                singleton = new FrameSkeletonManager();
            return singleton;
        }

        public void addSkeletonFrame(FrameSkeleton frmSkeleton, int index)
        {
            //Ensure we are in the allowed range
            index = (index > list.Count) ? list.Count : index;

            //Check if we need to add another new framelist to our manager.
            //If not, just add the FrameSkeleton to its corresponding list
            if (index == list.Count)
                list.Add(new FrameSkeletonList().Items.Add(frmSkeleton));
            else
                ((FrameSkeletonList)list[index]).Items.Add(frmSkeleton);
            Log.write("Kinect Device: " + index + "FrameSkeleton: " + ((FrameSkeletonList)list[index]).Items.Count);
        }



    }
}
